<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="utf-8">
    <title>车辆状态</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/static/layui/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/static/layui/css/public.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form">
    <blockquote class="layui-elem-quote quoteBox">
        <form class="layui-form">
            <div class="layui-inline">
                <div class="layui-inline">
                    <h5>选择车辆：</h5>
                </div>
                <div class="layui-input-inline">
                    <select id="carplate" lay-verify="required">
                    </select>
                </div>
                <div class="layui-inline">
                    <h5>使用情况：</h5>
                </div>
                <div class="layui-input-block layui-inline">
                    <select id="carable" lay-verify="required">
                        <option></option>
                        <option value="1">使用中的车辆</option>
                        <option value="2">空闲车辆</option>
                    </select>
                </div>
                <a class="layui-btn search_btn" data-type="reload"  id="searchVal">搜索</a>
            </div>
        </form>
    </blockquote>
    <table id="carStatusList" lay-filter="carStatusList"></table>

</form>
<script type="text/javascript" src="/static/layui/layui/layui.js"></script>
<script>
    layui.use(['form','layer','laydate','table','laytpl'],  function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laytpl = layui.laytpl,
            table = layui.table,
            laydate=layui.laydate;

        //用户列表
        var tableIns = table.render({
            elem: '#carStatusList',
            url : '/car/selectCarStatus',
            cellMinWidth : 95,
            page : true,
            height : "full-125",
            limits : [5,10,15,20,25],
            limit : 5,
            id : "userListTable",
            cols : [[
                {field: 'carplate', title: '车牌号', minWidth:300, align:"center"},
                {field: 'driver', title: '司机', minWidth:100, align:"center",templet:function (d) {
                        return d.driver.dirvername;
                    }},
                {field: 'car_startkm', title: '里程(km)', minWidth:100, align:"center"},
                {field: 'carable', title: '状态', minWidth:100, align:"center",templet:function (d) {
                            if(d.carable == 1){
                                return '已出车'
                            }else if(d.carable ==2){
                                return '未出车'
                            }else if(d.carable ==3){
                                return '维修中'
                            }
                    }}
            ]]
        });

        //动态展示所有的公务用车
        $.ajax({
            url:"/car/selectCarStatus",
            type:"get",
            success:function (data) {
                var message = "<option></option>";
                $.each(data.data,function (index,cars) {
                    message += "<option value="+cars.carid+">"+cars.carplate+"</option>";
                });
                $("#carplate").html(message);
                form.render('select');
            }
        });
        //搜索
        $("#searchVal").click(function () {
            var carid=$('#carplate').val();
            var carable=$('#carable').val();
            tableIns.reload({
                where:{
                    carid:carid,
                    carable:carable
                }
            })
        });

    });

</script>
</body>
</html>